<template>
    <h1>
        <el-button type="danger" @click="()=>{ this.$router.back();}">{{msg}}+{{data.msgType}}
        </el-button>
    </h1>

</template>

<script>
    import {WebSocketMixin} from "../../mixins/webSocketMixins"

    export default {
        name: "testRouter",
        mixins: [WebSocketMixin],
        data() {
            return {
                msg: "Hello World",
                message: {},
                data: {}
            }
        },
        created() {
            this.msg = this.$route.query.msg;
        },
        methods: {
            webSocketOnMessage: function (e) {
                // 用于接收
                this.message = e;
                console.log("所有信息---", this.message);
                console.log("接收内容---", this.message.data);
                this.data = JSON.parse(this.message.data);
                console.log("类型", this.data.msgType);
            },
            webSocketSend(text) {
                // 数据发送
                try {
                    this.websock.send(text);
                } catch (err) {
                    console.log("send failed (" + err.code + ")");
                }
            },

        }
    }
</script>

<style scoped>

</style>
